/**
 *
 */
Ext.define('vacake.view.MoreInfo', {
    extend: 'Ext.Container',
    xtype: 'moreInfo',
    config: {
        layout: 'vbox',
        items: [
            {
                docked: 'top',
                xtype: 'titlebar',
                title:'',
                id: 'titleBar',
                items: {
                    text: '返回', ui: 'action-back',
                    handler: function () {
                        window.localStorage.removeItem('more_caid');
                        Ext.Viewport.remove(this.up('moreInfo'), true);
                    }
                }
            },
            {
                xtype:'panel',
                flex:5,
                scrollable:true,
                id: 'infoHtml',
                html:'',
                cls:'font2 color2 height20',
                style:'margin:5px 5px;'
            }
        ],
        listeners: {
            initialize: function () {
                Ext.Viewport.mask({ xtype: 'loadmask', message: '加载数据中...' });
                var moreCaId = window.localStorage.getItem('more_caid');
                Ext.Ajax.request({
                    url: Global.api_url + '/cloud/1/article_info_get',
                    params: {caid: moreCaId},
                    method: 'POST',
                    scope: this,
                    success: function (response) {
                        Ext.Viewport.unmask();
                        var returnText = Ext.decode(response.responseText);
                        if (returnText.Variables.Result.code == 0) {
                            var length=returnText.Variables.data.photos.length;
                            var image='';
                            //添加图片
                            for(var i= 0;i<length;i++){
                                image+='<img src='+returnText.Variables.data.photos[i].url+' width="80%"  style="margin:0 10%" />'
                            }
                            Ext.getCmp('titleBar').setTitle(returnText.Variables.data.name);

                            //加载咨询详细内容
                            Ext.getCmp('infoHtml').setHtml(
                                '<div style="padding: 5px 5px 10px 5px">' +
                                    image+
                                    '<div>' + returnText.Variables.data.content + '</div>' +
                                    '</div>'
                            )

                            //Ext.getCmp('infoHtml').setHtml(returnText.Variables.data.content);
                        }
                    },
                    failure: function () {//请求失败时执行操作
                        Ext.Viewport.unmask();
                        cordova.exec(function(message){}, function(error){}, "Messages", "showMsg", ['请求失败,服务器维护中...']);
//                        Ext.Msg.alert('请求失败', '服务器维护中....');
                    }
                })
            },
            back: function() {
                 window.localStorage.removeItem('more_caid');
                Ext.Viewport.remove(Ext.Viewport.getActiveItem(), true);
            }
        }
    }

});

